﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            // String str = @"server = PCOS-1710141132\SQLEXPRESS; uid = sa; pwd = 123456; database = Style";
            // SqlConnection sqlConnection = new SqlConnection(str);
            // sqlConnection.Open();
            // SqlCommand sqlCommand = new SqlCommand("select * from Table_1", sqlConnection);
            // var reader = sqlCommand.ExecuteReader();
            // while (reader.Read())
            //{
            //     Console.WriteLine("{0}\t{1}\t{2}",reader["Id"],reader["Name"],reader["Age"]);
            // }

            
            String str = @"server = PCOS-1710141132\SQLEXPRESS; uid = sa; pwd = 123456; database = Style";
            SqlConnection sqlConnection = new SqlConnection(str);
            sqlConnection.Open();
            string cmdString = "select * from Table_1";
            DataTable table = new DataTable();
            SqlDataAdapter dataAdapter = new SqlDataAdapter(cmdString,sqlConnection);
            dataAdapter.Fill(table);
            foreach (DataRow row in table.Rows)
            {
                Console.WriteLine("{0}\t{1}\t{2}",row["Id"],row["name"],row["Age"]);
            }

           

        }
    }
}
